/**
 *	流程模块接口文件：todo消息提醒
 *	开发者：雨中磐石
 *	地址：www.rockoa.com
 *	日期：2023-07-19
 */

package com.framework.Module.base.todo;




import com.framerock.baselib.Rock;
import com.framework.Flow.FlowListener;

import java.util.Map;


public class FlowListenertodo extends FlowListener {

    @Override
    public Boolean onisAdd() {
        return true;//让任何人都可用添加
    }

    @Override
    public Boolean onModejs() {
        return true;
    }

    @Override
    public Boolean onisDelete() {
        if(mFlow.isMydj())return true;
        return super.onisDelete();
    }

    @Override
    public void onFlowunitadd() {
        mFlow.updateUnit(Rock.getMap("issx=1"), mFlow.funitid, "");
    }

    @Override
    public Map<String, String> onReplacers(Map<String, String> da, int lx) {
        String zt = da.get("status");
        if(zt.equals("1")){
            da.put("isrowhui", "1");
        }else{
            da.put("isrowhui", "0");
        }
        if(lx==1){
           if(zt.equals("0"))mFlow.mModel.update("`status`=1", da.get("id"));
        }
        return da;
    }

    @Override
    public String onAction(String act, String params) {
        if(act.equals("biaoyidu"))mFlow.mModel.update("`status`=1", "`aid`="+mRequest.USEAID+"");
        if(act.equals("clearall"))mFlow.mModel.delete("`aid`="+mRequest.USEAID+"");
        return super.onAction(act, params);
    }

    //首页上显示统计未读的
    public Map<String, String> onhomeData(String pnum) {
        Map<String, String> da = Rock.getMap();
        da.put("total", ongetStotal("")+"");
        return da;
    }

    @Override
    public int ongetStotal(String pnum) {
        int to = 0;
        if(Rock.isEmpt(pnum)){
            String where = "`cid`="+mRequest.COMPANYID+" AND `status`=0 AND `aid`="+mRequest.USEAID+"";
            to  = mFlow.mModel.getCount(where);
        }
        return to;
    }
}
